package com.order.manager.service.impl;

import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.page.PageMethod;
import com.order.manager.Model.ComplaintInfo;
import com.order.manager.service.ComplaintInfoService;
import com.order.manager.mapper.ComplaintInfoMapper;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 24862
* @description 针对表【complaint_info】的数据库操作Service实现
* @createDate 2024-04-08 15:32:07
*/
@Service
public class ComplaintInfoServiceImpl extends ServiceImpl<ComplaintInfoMapper, ComplaintInfo>
    implements ComplaintInfoService{

    @Resource
    ComplaintInfoMapper mapper;

    @Resource
    UserInfoServiceImpl userInfoService;


    @Override
    public PageInfo<ComplaintInfo> queryList(int page, int item, String content) {
        PageMethod.startPage(page,item);
        List<ComplaintInfo> complaintInfos = mapper.selectList(new QueryWrapper<ComplaintInfo>()
                .like("content", content)
        );
        complaintInfos.forEach(el-> el.setUserId(JSON.toJSONString(userInfoService.getById(el.getUserId()))));
        return new PageInfo<>(complaintInfos);
    }
}




